package sendorder;

import guis.FunctionalControls;

import org.eclipse.swt.widgets.Composite;

import dao.DataLoader;

public class SendOrdersControls implements FunctionalControls,
	SendOrderInterface {

    DataLoader dao;
    OrderCollector fullOrder;
    SendOrderGUI gui;

    public SendOrdersControls(Composite tshell, DataLoader dao) {
	this.dao = dao;
	gui = new SendOrderGUI(this, tshell);
	fullOrder = new OrderCollector(dao);

	gui.showMenu(dao.getMenu());

	gui.setFullCost(fullOrder.getFullCost());

	// 10% sale for order >1000
	// TODO Load from settings
	gui.setEconomize(fullOrder.getFullCost() > (1000 * (1 - 0.1)));

	gui.setMeanCost(fullOrder.getMeanCost());

	gui.applyOrderToMenu(fullOrder.getFullOrder());

	for (String user : fullOrder.getUsers()) {
	    gui.addUser(user);
	}
    }

    public void disposeControls() {
	//
    }

    @Override
    public void close() {
	gui.close();
    }

    @Override
    public void sendOrder() {
	// TODO print all orders to fax

    }

    @Override
    public void printUserOrders() {
	// TODO print orders for users

    }

}
